import Vue from 'vue'

/**
 * 全局指令
 */

// 权限指令
const has = Vue.directive('has', {
    bind: (el, binding) => {
        let userInfo = JSON.parse(sessionStorage.getItem('vuejs__loginUser')).value
        if (!userInfo.isSuperAdmin && binding.value) {
            let permissions = userInfo.authorityIds ? userInfo.authorityIds : []
            if (permissions.indexOf(binding.value) < 0) {
                el.parentNode.removeChild(el)
            }
        }
    }
})

export default {
    has
}
